package com.lily.aidouzixun.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.JSONObject;

/**
 * 动态信息
 */
public class DynamicCommentInfo implements Parcelable {

    /**
     * Json key
     */
    private static final String CMTID_JSONKEY= "CMTID";
    private static final String AVATAR_JSONKEY= "Avatar";
    private static final String NICKNAME_JSONKEY= "NickName";
    private static final String URID_JSONKEY= "URID";
    private static final String UDID_JSONKEY= "UDID";
    private static final String DID_JSONKEY= "DID";
    private static final String CREATED_TIME_JSONKEY= "CreatedTime";
    private static final String UPDATED_TIME_JSONKEY= "UpdatedTime";
    private static final String CONTENT_JSONKEY= "Content";
    private static final String STATE_JSONKEY = "State";
    private static final String RCMTID_JSONKEY = "RCMTID";
    private static final String RURID_JSONKEY = "RURID";
    private static final String TYPE_JSONKEY = "Type";   //1为真实用户点评/2为虚拟用户点评

    /**
     * 属性值
     */
    private String cmtid;
    private String avatar;
    private String nickname;
    private String urid;
    private String udid;
    private String did;
    private String createdTime;
    private String updatedTime;
    private String content;
    private int state;  //1为待审核/2为审核通过/3为审核不通过
    private String rcmtid;
    private String rurid;
    private int type;	//状态 1-真实用户;2-匿名用户


    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getCmtid() {
        return cmtid;
    }

    public void setCmtid(String cmtid) {
        this.cmtid = cmtid;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(String createdTime) {
        this.createdTime = createdTime;
    }

    public String getDid() {
        return did;
    }

    public void setDid(String did) {
        this.did = did;
    }

    public String getRcmtid() {
        return rcmtid;
    }

    public void setRcmtid(String rcmtid) {
        this.rcmtid = rcmtid;
    }

    public String getRurid() {
        return rurid;
    }

    public void setRurid(String rurid) {
        this.rurid = rurid;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getUdid() {
        return udid;
    }

    public void setUdid(String udid) {
        this.udid = udid;
    }

    public String getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(String updatedTime) {
        this.updatedTime = updatedTime;
    }

    public String getUrid() {
        return urid;
    }

    public void setUrid(String urid) {
        this.urid = urid;
    }

    /**
     * 解析评论数据
     * @param jsonObj
     * @return
     */
    public static DynamicCommentInfo parseInfo(JSONObject jsonObj) {
        if (jsonObj == null) {
            return null;
        }
        DynamicCommentInfo discussComment = new DynamicCommentInfo();
        if (jsonObj.has(CMTID_JSONKEY)) {
            discussComment.setCmtid(jsonObj.optString(CMTID_JSONKEY));
        }
        if (jsonObj.has(URID_JSONKEY)) {
            discussComment.setUrid(jsonObj.optString(URID_JSONKEY));
        }
        if (jsonObj.has(AVATAR_JSONKEY)) {
            discussComment.setAvatar(jsonObj.optString(AVATAR_JSONKEY));
        }
        if (jsonObj.has(NICKNAME_JSONKEY)) {
            discussComment.setNickname(jsonObj.optString(NICKNAME_JSONKEY));
        }
        if (jsonObj.has(UDID_JSONKEY)) {
            discussComment.setUdid(jsonObj.optString(UDID_JSONKEY));
        }
        if (jsonObj.has(DID_JSONKEY)) {
            discussComment.setDid(jsonObj.optString(DID_JSONKEY));
        }
        if (jsonObj.has(CREATED_TIME_JSONKEY)) {
            discussComment.setCreatedTime(jsonObj.optString(CREATED_TIME_JSONKEY));
        }
        if (jsonObj.has(UPDATED_TIME_JSONKEY)) {
            discussComment.setUpdatedTime(jsonObj.optString(UPDATED_TIME_JSONKEY));
        }
        if (jsonObj.has(CONTENT_JSONKEY)) {
            discussComment.setContent(jsonObj.optString(CONTENT_JSONKEY));
        }
        if (jsonObj.has(STATE_JSONKEY)) {
            discussComment.setState(Integer.parseInt(jsonObj.optString(STATE_JSONKEY)));
        }
        if (jsonObj.has(TYPE_JSONKEY)) {
            discussComment.setType(Integer.parseInt(jsonObj.optString(TYPE_JSONKEY)));
        }
        if (jsonObj.has(RCMTID_JSONKEY)) {
            discussComment.setRcmtid(jsonObj.optString(RCMTID_JSONKEY));
        }
        if (jsonObj.has(RURID_JSONKEY)) {
            discussComment.setRurid(jsonObj.optString(RURID_JSONKEY));
        }

        return discussComment;
    }

    /**
     * 序列化实体类
     */
    public static final Creator<DynamicCommentInfo> CREATOR = new Creator<DynamicCommentInfo>() {
        public DynamicCommentInfo createFromParcel(Parcel source) {
            DynamicCommentInfo discussComment = new DynamicCommentInfo();
            discussComment.cmtid = source.readString();
            discussComment.avatar = source.readString();
            discussComment.nickname = source.readString();
            discussComment.urid = source.readString();
            discussComment.udid = source.readString();
            discussComment.did = source.readString();
            discussComment.createdTime = source.readString();
            discussComment.updatedTime = source.readString();
            discussComment.content = source.readString();
            discussComment.state = source.readInt();
            discussComment.type = source.readInt();
            discussComment.rcmtid = source.readString();
            discussComment.rurid = source.readString();
            return discussComment;
        }

        public DynamicCommentInfo[] newArray(int size) {
            return new DynamicCommentInfo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(cmtid);
        parcel.writeString(urid);
        parcel.writeString(avatar);
        parcel.writeString(nickname);
        parcel.writeString(udid);
        parcel.writeString(did);
        parcel.writeString(createdTime);
        parcel.writeString(updatedTime);
        parcel.writeString(content);
        parcel.writeInt(state);
        parcel.writeInt(type);
        parcel.writeString(rcmtid);
        parcel.writeString(rurid);

    }
}
